<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <form>
        <label for="stu_id">学号：</label>
        <input type="text" id="stu_id"><br>

        姓名：<input type="text" class="stu_name"><br>

        性别：<input type="text" class="stu_sex"><br>

        出生日期：<input type="text" class="stu_data"><br>

        爱好：<input type="text" class="stu_hoppy"><br>

        男女朋友：<input type="text" class="stu_bgf"><br>

        头像：<input type="text" class="stu_head_img"><br>

    </form>
    <button class="btn_student_info">提交学生信息</button>
    <script src="../jquery/jquery-1.12.4.min.js"></script>

    <script>
        $('.btn_student_info').click((e)=>{
            e.preventDefault();  //取消浏览器的默认提交功能

            $.ajax({
                method:'post',
                url:"http://localhost:3000/student_info",
                data:{
                   stu_id:$('#stu_id').val(),
                   stu_name: $('.stu_name').val(),
                   stu_sex:$('.stu_sex').val(),
                   stu_jg:$('.stu_jg').val(),
                   stu_gbf:$('.stu_gbf').val(),
                   stu_hoppy:$('.stu_hoppy').val(),
                   stu_head_img:$('.stu_head_img').val()
                },
                success:(data)=>{
                    console.log(data);
                },
                error:(err)=>{
                    console.log(err);
                }
            })

        })
    </script>

</body>
</html>